(library (json-reader)
  (export print-json
          get-json-from-file)
  (import (rnrs base)
          (rnrs bytevectors)
          (only (guile)
                lambda* λ
                call-with-input-file
                set-port-encoding!
                display
                simple-format)
          ;; GNU Guile batteries
          (ice-9 format)
          ;; SRFIs
          ;; SRFI-1 - list procedures
          (srfi srfi-1)
          ;; SRFI-43 - vectors
          (srfi srfi-43)
          ;; external libraries
          (json)))


(define print-json
  (lambda* (the-json)
    (display (simple-format #f "~a\n" (scm->json-string the-json #:unicode #f #:pretty #t)))))


(define get-json-from-file
  (λ (file-path)
    (call-with-input-file file-path
      (λ (port)
        (set-port-encoding! port "UTF-8")
        (json->scm port)))))
